package com.chris.oauth2.web.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chris.oauth2.JsonResult;
import com.chris.oauth2.service.AuthService;

@Controller
@RequestMapping("rest")
public class RestResourceController {

	@Autowired
	AuthService authService;

	@RequestMapping("test")
	public @ResponseBody JsonResult initRestResources(@RequestParam String token) {
		if (authService.checkAccessToken(token)) {
			return new JsonResult(0, "SUCCESS");
		} else {
			return new JsonResult(1, "ERROR");
		}
	}

}
